//
//  LYTabbarViewController.swift
//  WeChat
//
//  Created by mac on 2018/7/24.
//  Copyright © 2018年 RRC. All rights reserved.
//

import UIKit
import TimedSilver


class LYTabbarViewController: UITabBarController {

    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        self.setUpViewController()
        
    }

    func setUpViewController() -> Void {
        let titleArray = ["微信", "通讯录", "发现", "我"]
        
        let normalImagesArray = [
            LYAsset.Tabbar_mainframe.image,
            LYAsset.Tabbar_contacts.image,
            LYAsset.Tabbar_discover.image,
            LYAsset.Tabbar_me.image
        ]
        
        let selectedImagesArray = [
            LYAsset.Tabbar_mainframeHL.image,
            LYAsset.Tabbar_contactsHL.image,
            LYAsset.Tabbar_discoverHL.image,
            LYAsset.Tabbar_meHL.image
        ]
        
        let viewControllerArray = [
            LYMessageViewController(),
            LYContactViewController(),
            LYDiscoverViewController(),
            LYMeViewController()
        ]
        
        var navigationVCArray = Array<UIViewController>()
        for (index, controller) in viewControllerArray.enumerated() {
            controller.tabBarItem!.title = titleArray[index]
            controller.tabBarItem!.image = normalImagesArray[index].withRenderingMode(.alwaysOriginal)
            controller.tabBarItem!.selectedImage = selectedImagesArray[index].withRenderingMode(.alwaysOriginal)
        controller.tabBarItem!.setTitleTextAttributes([NSAttributedStringKey.foregroundColor:UIColor.lightGray], for: .normal)
            controller.tabBarItem!.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.tabbarSelectedTextColor], for: .selected)
            let navigationController = UINavigationController(rootViewController: controller)
            navigationVCArray.append(navigationController)
        }
        self.viewControllers = navigationVCArray
    }
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
